package com.tobby.camel.camelinaction.chapter3.transform;

import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.CamelSpringTestSupport;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringTransformMethodTest extends CamelSpringTestSupport {

	@Override
	protected AbstractApplicationContext createApplicationContext() {
		return new ClassPathXmlApplicationContext(
				"com/tobby/camel/camelinaction/chapter3/transform/spring-method.xml");
	}

	@Test
	public void testTransform() throws InterruptedException {
		MockEndpoint endpoint = getMockEndpoint("mock:result");
		endpoint.expectedBodiesReceived("<body>Hello<br/>How are you?</body>");

		template.sendBody("direct:start", "Hello\nHow are you?");
		assertMockEndpointsSatisfied();
	}

}
